@echo off
call:genProto auth
call:genProto rental
call:genProto blob 1
call:genProto car
call:genProto coolenv 1
goto genProto_end

:genProto
set DOMAIN=%1
set SKIP_GATEWAY=%2
set PROTO_PATH=.\%DOMAIN%\api
set GO_OUT_PATH=.\%DOMAIN%\api\gen\v1

IF NOT EXIST %GO_OUT_PATH% (
    mkdir %GO_OUT_PATH%
)

protoc -I=%PROTO_PATH% --go_out=paths=source_relative:%GO_OUT_PATH% --go_opt=paths=source_relative --go-grpc_out=paths=source_relative:%GO_OUT_PATH% --go-grpc_opt=paths=source_relative %DOMAIN%.proto

if defined SKIP_GATEWAY (
	goto :eof
)

protoc -I=%PROTO_PATH% --grpc-gateway_out=paths=source_relative:%GO_OUT_PATH% --grpc-gateway_opt paths=source_relative --grpc-gateway_opt grpc_api_configuration=%PROTO_PATH%\%DOMAIN%.yaml %DOMAIN%.proto
:genProto_end
